//
//  List3ViewController.m
//  225视听百科
//
//  Created by 张元阳(10) on 14-12-29.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "List3ViewController.h"
#import "ConnectModel.h"
#import "Custom3Button.h"
#import "UIImageView+WebCache.h"
#import "list4ViewController.h"
@interface List3ViewController ()

@end

@implementation List3ViewController
- (void)dealloc
{
    [_list3Array release];
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.list3Array = [NSMutableArray array];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self createList];
}

- (void)createList
{
    NSString *str = [NSString stringWithFormat:@"http://app.9nali.com/777/selected/%ld?page_id=1&device=iPhone&version=1.1.5", self.Id];
    [ConnectModel connectModelWithUrl:str parmaters:nil finished:^(NSData *getData) {
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:getData options:NSJSONReadingMutableLeaves error:nil];
        NSMutableArray *array = [dic objectForKey:@"list"];
        [_list3Array addObjectsFromArray:array];
        
        NSDictionary *dicc = [_list3Array objectAtIndex:0];
        Custom3Button *button = [[Custom3Button alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, 50)];
        button.backgroundColor = [UIColor lightGrayColor];
        NSString *str1 = [dicc objectForKey:@"album_cover_path_290"];
        [button.imageV1 setImageWithURL:[NSURL URLWithString:str1]];
        button.label1.text = [dicc objectForKey:@"title"];
        button.tag = [[dicc objectForKey:@"id"] integerValue];
        NSString *str3 = [NSString stringWithFormat:@"节目数 %@", [dicc objectForKey:@"tracks_counts"]];
        button.label2.text = str3;
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
        [button release];
        
    }];
}
- (void)buttonAction:(Custom3Button *)sender
{
    list4ViewController *list = [[list4ViewController alloc] init];
    [self.navigationController pushViewController:list animated:YES];
    list.Id = sender.tag;
    [list release];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
